package com.hifar.demo3;

import java.io.InputStream;
import java.io.FileInputStream;

import com.hifar.demo3.model.DmData;

public class WordReportExample {
    public static void main(String[] args) {
        try {
            // 1. 解析DM文件
            S1000DParser dmParser = new S1000DParser();
            InputStream dmStream = new FileInputStream("src/main/resources/data/DXJG0001A.xml");

            DmData dmData = dmParser.parse(dmStream);
            
            // 2. 解析操作数据文件
            OperationDataParser opParser = new OperationDataParser();
            InputStream opStream = new FileInputStream("src/main/resources/data/DATA-DXJG0001A.xml");
            opParser.parse(opStream);
            
            // 3. 将操作数据解析器设置到DM解析器中
            dmParser.setOperationDataParser(opParser);
            
            // 4. 重新解析DM文件以填充操作数据
            dmStream = new FileInputStream("src/main/resources/data/DXJG0001A.xml");
            dmData = dmParser.parse(dmStream);
            
            // 5. 生成Word报告
            WordReportGenerator generator = new WordReportGenerator();
            generator.generateReport(dmData, "output/检查报告.docx");
            
            System.out.println("Word文档生成成功！");
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
